GoodReadsPaginatedSearchResults

class GoodReadsPaginatedSearchResults(searchUrl: String)

Wrapper of GoodReadsSearchResult that can be used to fetch more than the results of the first page.

Samples

import ch.derlin.grmetafetcher.GoodReadsLookup
import ch.derlin.grmetafetcher.GoodReadsMetadata
import ch.derlin.grmetafetcher.GoodReadsPaginatedSearchResults
import ch.derlin.grmetafetcher.Retry
import ch.derlin.grmetafetcher.RetryConfiguration
fun main() { 
   //sampleStart 
   val paginatedResults: GoodReadsPaginatedSearchResults = GoodReadsLookup("how time war").getMatchesPaginated()
println("Found ${paginatedResults.totalResults} results across ${paginatedResults.totalPages} pages")
println("Showing only first result of all pages...")
println()

while (paginatedResults.hasNext()) {
    paginatedResults.next().first().let {
        println("page [${paginatedResults.currentPage}] --> \"${it.title}\" by ${it.authorsStr}")
    }
} 
   //sampleEnd
}

See also

Constructors

Link copied to clipboard
fun GoodReadsPaginatedSearchResults(searchUrl: String)

Functions

Link copied to clipboard
fun allResults(): List<GoodReadsSearchResult>

Return all the fetched results so far.

Link copied to clipboard
fun hasNext(): Boolean

Returns true if there are more results available (a next page is present), should always be called prior to next.

Link copied to clipboard
fun next(): List<GoodReadsSearchResult>

Fetch the next list of results from the page, also updating the results list.

Properties

Link copied to clipboard
var currentPage: Int = 0

Latest fetched page, 0 if next has never been called.

Link copied to clipboard
val totalPages: Int

Total number of result pages available, or zero if no result.

Link copied to clipboard
val totalResults: Int

Total number of results available, or zero if no result.

Sources

Link copied to clipboard